package com.GlobalPaint.app.ui.Home.friend;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import com.GlobalPaint.app.R;
import com.jzy.message.activities.MsgFragment;
import com.jzy.message.service.MsfService;
import com.jzy.message.util.xmpp.Const;
import com.jzy.message.util.xmpp.PreferencesUtils;

public class Activity_Message extends FragmentActivity {

    Activity_Message thisActivity=null;
    //Message功能
    private MsgFragment frgMsg;
    // 定义fragementManager
    FragmentManager fManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity__message);
        thisActivity=this;
        //默认开启声音和震动提醒(XMPP消息提醒)
        PreferencesUtils.putSharePre(Activity_Message.this, Const.MSG_IS_VOICE, true);
        PreferencesUtils.putSharePre(Activity_Message.this, Const.MSG_IS_VIBRATE, true);
        fManager = getSupportFragmentManager();
        startXMPPService();//启动XMPP服务，登录的用户密码已经在Login页面保存
        // 隐藏所有的Fragment
        FragmentTransaction fragmentTrans = fManager.beginTransaction();
        if(frgMsg == null){
            frgMsg = new MsgFragment();
            fragmentTrans.add(R.id.app_content, frgMsg);
        }
        fragmentTrans.commit();
    }
    private void  startXMPPService()
    {
        //启动核心Service
        Intent intent=new Intent(thisActivity,MsfService.class);
        startService(intent);
    }
}
